package day13.mapdemo;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;

public class demo1 {
    public static void main(String[] args) {
        //键值对，键不能重复，值可以重复
         Map<String,String> map=new HashMap<>();
         map.put("1","小王");
         map.put("2","小明");
         map.put("3","小红");
         map.put("1","小明");//保留最后一个值，把小王顶掉了
        System.out.println(map);

        Map<String,String> map2=new LinkedHashMap<>();
        map2.put("1","小王");
        map2.put("2","小明");
        map2.put("3","小红");
        map2.put("1","小明");//保留最后一个值，把小王顶掉了
        map2.put("2","小李");//保留最后一个值，把小明顶掉了
        System.out.println(map2);

        Map<String,String> map3=new TreeMap<>();
        map3.put("1","小王");
        map3.put("2","小明");
        map3.put("3","小红");
        map3.put("1","小明");//保留最后一个值，把小王顶掉了
        map3.put("2","小李");//保留最后一个值，把小明顶掉了
        System.out.println(map3);



    }
}
